package com.publicize.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.publicize.entity.ExaminationDetail;
import com.publicize.entity.Option;
import com.publicize.entity.Vo.option;
import com.publicize.mapper.ExaminationDetailMapper;
import com.publicize.service.ExaminationDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 知识竞赛题目表 服务实现类
 * </p>
 *
 * @author bs
 * @since 2021-03-05
 */
@Service
public class ExaminationDetailServiceImpl extends ServiceImpl<ExaminationDetailMapper, ExaminationDetail> implements ExaminationDetailService {
    @Override
    public List<Option> getOptionList(String number) {
        QueryWrapper<ExaminationDetail> examinationDetailQueryWrapper=new QueryWrapper<>();
        examinationDetailQueryWrapper.eq("examination_number",number);
        List<ExaminationDetail> examinationDetails = baseMapper.selectList(examinationDetailQueryWrapper);
        List<Option> optionList=new ArrayList<>();

        for (int i=0;i<examinationDetails.size();i++){
            Option option=new Option();
            BeanUtils.copyProperties(examinationDetails.get(i),option);
            optionList.add(option);
        }
        return optionList;
    }

//    @Override
//    public List<Option> getOptionList(String number) {
//        QueryWrapper<ExaminationDetail> examinationDetailQueryWrapper=new QueryWrapper<>();
//        examinationDetailQueryWrapper.eq("",number);
//        List<ExaminationDetail> examinationDetails = baseMapper.selectList(examinationDetailQueryWrapper);
//        List<Option> optionList=new ArrayList<>();
//        Option option=new Option();
//        for (int i=0;i<examinationDetails.size();i++){
//            //赋值
//            /*String answer = examinationDetails.get(i).getAnswer();
//            String optionA = examinationDetails.get(i).getOptionA();
//            String optionB=examinationDetails.get(i).getOptionB();
//            String optionC = examinationDetails.get(i).getOptionC();
//            String optionD = examinationDetails.get(i).getOptionD();*/
//            BeanUtils.copyProperties(examinationDetails.get(i),option);
//            optionList.add(option);
//        }
//        return optionList;
//
//    }
}
